'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.createTable('car', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      license_plate: {
        type: Sequelize.STRING(20),
        unique: true,
        comment: '车牌号'
      },
      driver_name: {
        type: Sequelize.STRING(50),
        comment: '驾驶员姓名'
      },
      driver_phone: {
        type: Sequelize.STRING(20),
        comment: '驾驶员手机号'
      },
      status: {
        type: Sequelize.TINYINT,
        defaultValue: 1,
        comment: '状态：1-正常，0-删除'
      },
      create_time: {
        allowNull: false,
        type: Sequelize.DATE,
        defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
      },
      update_time: {
        allowNull: false,
        type: Sequelize.DATE,
        defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
      }
    });
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('car');
  }
};
